package com.heima.Listener;

import com.alibaba.fastjson.JSON;
import com.heima.Server.impl.ArticleService;
import com.heima.model.common.Pojos.WAMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class listener {
    @Autowired
    ArticleService articleService;

//    接收来自文章微服务的消息
    @RabbitListener(queues = "Article.queue")
    public void DownOrUp(String waMessage)
    {
        log.info("接收到了消息");
//        下架文章
        WAMessage message = JSON.parseObject(waMessage, WAMessage.class);
        articleService.DownOrUpArtiler(message.getArticleId(),message.getIsDown());
    }
}
